/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxt.DAO;

import com.cxt.Bean.MonitorManifiestoBean;
import com.cxt.Util.ConexionSQL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author jgutierrez
 */
public class MonitorManifiestoDAO {
    
    public ArrayList<MonitorManifiestoBean> listarMonitorManifiesto() {
        
        ArrayList<MonitorManifiestoBean> lista = new ArrayList<MonitorManifiestoBean>();
        
        Connection con = null;
        PreparedStatement pst = null;
        ResultSet rs = null;
        
        
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            con = ConexionSQL.obtenerConexion();
            String query = "select MANIFIESTO, NAVE, AGENCIA, NROCONTENEDORES, ESTADO, FECHADESCARGA from MonitorManifiesto;";
            //String query = "select * from Transmisiones";
            pst = con.prepareStatement(query);
            rs = pst.executeQuery();
            
            MonitorManifiestoBean objMM;
            
            while (rs.next()) {
                objMM = new MonitorManifiestoBean();
                
                objMM.setCodManifiesto(rs.getString("MANIFIESTO"));
                objMM.setNave(rs.getString("NAVE"));
                objMM.setAgencia(rs.getString("AGENCIA"));
                objMM.setNroContenedores(rs.getInt("NROCONTENEDORES"));
                objMM.setFechaDescarga(rs.getDate("FECHADESCARGA"));
                
                lista.add(objMM);
            }
            
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(MonitorManifiestoDAO.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(MonitorManifiestoDAO.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return lista;
    }
    
}
